package com.weasel.weixin.commons.message.builder;

import com.weasel.weixin.commons.message.bean.WeiXinPostCommonXmlAnswerMusicMessage;

/**
 * Created by Dylan on 2015/10/12.
 */
public class WeixinPostCommonXmlAnswerMusicMessageBuilder extends AbstractWeixinPostCommonXmlAnswerMessageBuilder<WeixinPostCommonXmlAnswerMusicMessageBuilder,WeiXinPostCommonXmlAnswerMusicMessage>{

    public WeixinPostCommonXmlAnswerMusicMessageBuilder() {
        super(new WeiXinPostCommonXmlAnswerMusicMessage());
    }

    public WeixinPostXmlAnswerMusicBodyMessageBuilder addArticle(){

        return new WeixinPostXmlAnswerMusicBodyMessageBuilder(this);
    }

    public static class WeixinPostXmlAnswerMusicBodyMessageBuilder{

        private WeixinPostCommonXmlAnswerMusicMessageBuilder parent;

        private WeiXinPostCommonXmlAnswerMusicMessage.MusicBody body = new WeiXinPostCommonXmlAnswerMusicMessage.MusicBody();

        public WeixinPostXmlAnswerMusicBodyMessageBuilder(){
        }

        public WeixinPostXmlAnswerMusicBodyMessageBuilder(WeixinPostCommonXmlAnswerMusicMessageBuilder _parent){

            this.parent = _parent;
        }

        public WeixinPostXmlAnswerMusicBodyMessageBuilder title(String title){

            body.setTitle(title);
            return this;
        }

        public WeixinPostXmlAnswerMusicBodyMessageBuilder description(String description){

            body.setDescription(description);
            return this;
        }

        public WeixinPostXmlAnswerMusicBodyMessageBuilder musicUrl(String musicUrl){

            body.setMusicUrl(musicUrl);
            return this;
        }

        public WeixinPostXmlAnswerMusicBodyMessageBuilder hqMusicUrl(String hqMusicUrl){
             body.setHqMusicUrl(hqMusicUrl);
            return this;
        }

        public WeixinPostXmlAnswerMusicBodyMessageBuilder thumbMediaId(String thumbMediaId){
            body.setThumbMediaId(thumbMediaId);
            return this;
        }

        public WeixinPostCommonXmlAnswerMusicMessageBuilder end(){
            if(null == parent){
                throw new RuntimeException("请调用带参的构造方法，并传递WeixinPostCommonXmlAnswerImageMessageBuilder参数，否则请调用build方法");
            }
            ((WeiXinPostCommonXmlAnswerMusicMessage)parent.message).setMusic(build());
            return parent;
        }

        public WeiXinPostCommonXmlAnswerMusicMessage.MusicBody build(){
            return body;
        }

    }
}
